/**
*      author: Y_Yao
*      created: 2025-03-21 23:08:46
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int NK = 2e5 + 7;
int n,k;
vector<int> G[NK];
int sz[NK];

void NO()
{
    cout << "No" << endl;
    exit(0);
}

void dfs(int u,int fa)
{
    int ch = 0;
    sz[u] = 1;
    for(int i = 0;i < G[u].size();i++)
    {
        int v = G[u][i];
        if(v == fa) continue;
        dfs(v,u);
        if(sz[v])
        {
            ch++;
            sz[u] += sz[v];
        }
    }
    if(sz[u] < k)
    {
        if(u == 1 || ch > 1)
        {
            NO();
        }
    }
    else if(sz[u] == k)
    {
        if(ch > 2) NO();
        sz[u] = 0;
    }
    else
    {
        NO();
    }
}

void solve()
{
    cin >> n >> k;
    for(int i = 1;i <= n * k - 1;i++)
    {
        int u,v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,0);
    cout << "Yes" << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}